package com.eastfair.datasync.component;

import com.alibaba.fastjson.JSONObject;
import com.eastfair.auth.entity.UserAccount;
import com.eastfair.datasync.handler.ExhibitionSycnHandler;
import com.eastfair.datasync.handler.JsonSycnHandler;
import com.eastfair.datasync.handler.UserAccountSycnHandler;
import com.eastfair.venuebooking.entity.Exhibition;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class Kafkalistener {
    @Autowired
    UserAccountSycnHandler userAccountSycnHandler;

    @Autowired
    ExhibitionSycnHandler exhibitionSycnHandler;

    @Autowired
    JsonSycnHandler jsonSycnHandler;

    /**
     * topic
     *
     * @param record
     */
    @KafkaListener(topics = "db_kongur_common_c_user_account")
    public void userAccountOnMessage(ConsumerRecord<String, String> record) {
        log.info("db_kongur_common_c_user_account is execute ");
//        String msg = record.value();
//        log.info(msg);
//        userAccountSycnHandler.executeAll(msg, UserAccount.class);
        jsonSycnHandler.executeAll(record.value(), new JSONObject());
    }

    /**
     * topic
     *
     * @param record
     */
    @KafkaListener(topics = "example")
    public void example(ConsumerRecord<String, String> record) {
        log.info("example is execute ");
        String msg = record.value();
        System.out.println(msg);
    }

    /**
     * 同步 vb_exhibition
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_booking_vb_exhibition")
    public void syncVbExhibition(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }

    /**
     * 同步 vb_exhibition_space
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_booking_vb_exhibition_space")
    public void syncVbExhibitionSpace(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }





    /**
     * 同步 vb_space
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_booking_vb_space")
    public void syncVbSpace(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }

    /**
     * 同步 vb_space_category
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_booking_vb_space_category")
    public void syncVbSpaceCategory(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }


    /**
     * 同步 vb_space_category
     *
     * @param record
     */
    @KafkaListener(topics = "mice_exhibitor_exhibition")
    public void syncVbExhibitorExhibition(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }


    /**
     * 同步 vsm_work_overtime
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_services_manage_vsm_work_overtime")
    public void syncVsmWorkOvertime(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }


    /**
     * 同步 vsm_service_order
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_services_manage_vsm_service_order")
    public void syncVsmServiceOrder(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }


    /**
     * 同步 vsm_service_booking
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_services_manage_vsm_service_booking")
    public void syncVsmServiceBooking(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }


    /**
     * 同步 vsm_service_item
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_services_manage_vsm_service_item")
    public void syncVsmServiceItem(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }

    /**
     * 同步 vsm_service_item_detail
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_services_manage_vsm_service_item_detail")
    public void syncVsmServiceItemDetail(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }



    /**
     * 同步 db_mice_venue_services_manage_vsm_exhibition_manage
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_services_manage_vsm_exhibition_manage")
    public void syncVvsm_exhibition_manage(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }

    /**
     * 同步 db_mice_pay_pay_transaction_order
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_pay_pay_transaction_order")
    public void syncDb_mice_venue_booking(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }




    /**
     * 同步 db_mice_venue_booking_vb_customer_main
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_booking_vb_customer_main")
    public void syncvb_customer_main(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }

    /**
     * 同步 db_mice_venue_booking_vb_exhibition_customer
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_booking_vb_exhibition_customer")
    public void vb_exhibition_customer(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }





    /**
     * 同步 mice_exhibitor_PersonJoin
     *
     * @param record
     */
    @KafkaListener(topics = "mice_exhibitor_personjoin")
    public void mice_exhibitor_PersonJoin(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }



    /**
     * 同步 mice_exhibitor_Actor
     *
     * @param record
     */
    @KafkaListener(topics = "mice_exhibitor_actor")
    public void mice_exhibitor_Actor(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }



    /**
     * 同步 mice_exhibitor_Booth
     *
     * @param record
     */
    @KafkaListener(topics = "mice_exhibitor_booth")
    public void mice_exhibitor_Booth(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }


    @KafkaListener(topics = "db_mice_certificate_cert_certificate_user")
    public void sycnCertificateUser(ConsumerRecord<String, String> record) {
        log.info("db_mice_certificate_cert_certificate_user is execute ");
        jsonSycnHandler.executeAll(record.value(), new JSONObject());
    }

    @KafkaListener(topics = "db_mice_certificate_cert_certificate")
    public void sycnCertCertificate(ConsumerRecord<String, String> record) {
        log.info("db_mice_certificate_cert_certificate is execute ");
        jsonSycnHandler.executeAll(record.value(), new JSONObject());
    }


    @KafkaListener(topics = "db_mice_certificate_cert_certificate_order")
    public void sycnCertCertificateOrder(ConsumerRecord<String, String> record) {
        log.info("db_mice_certificate_cert_certificate_order is execute ");
        jsonSycnHandler.executeAll(record.value(), new JSONObject());
    }



    @KafkaListener(topics = "db_kongur_public_c_dictionary")
    public void sycnCertPublicDictionary(ConsumerRecord<String, String> record) {
        log.info("db_kongur_public_c_dictionary is execute ");
        jsonSycnHandler.executeAll(record.value(), new JSONObject());
    }


    @KafkaListener(topics = "db_kongur_public_c_dictionary_type")
    public void sycnCertPublicDictionaryType(ConsumerRecord<String, String> record) {
        log.info("db_kongur_public_c_dictionary_type is execute ");
        jsonSycnHandler.executeAll(record.value(), new JSONObject());
    }




    /**
     * 同步 vsm_service_category
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_services_manage_vsm_service_category")
    public void syncVsmServiceCategory(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }



    /**
     * 同步 vsm_service_specs
     *
     * @param record
     */
    @KafkaListener(topics = "db_mice_venue_services_manage_vsm_service_specs")
    public void syncVsmServiceSpecs(ConsumerRecord<String, String> record) {
        JSONObject jsonObject = new JSONObject();
        jsonSycnHandler.executeAll(record.value(), jsonObject);
    }

}
